package com.woniu.cq.medical.dao.mymapper;

import com.woniu.cq.medical.dao.CaseMapper;
import com.woniu.cq.medical.entity.Case;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.context.annotation.Primary;

import java.util.List;

/**
 * @Author: Klaus
 * @Date: 2020/9/7 10:52
 */
@Primary
public interface My_CaseMapper extends CaseMapper {

    /**
     * 根据身份证查询病例 已归档
     * @param idCard 身份证
     * @return 病例
     */
    @Select("SELECT case_id,case_patient_name,case_sex,case_access_time,\n" +
            "case_birthdate,case_age,case_phone_number,case_address,\n" +
            "case_attack_date,user_id,case_admission_count,case_morbidity,\n" +
            "case_initial_diagnose,doctor_id,case_competent_physician,\n" +
            "case_final_diagnose,case_discharge_date,prescription_id,\n" +
            "case_discharge_condition,case_comment,case_is_pigeonhole,\n" +
            "case_final_update_date,case_patient_id_card from lonbon_case \n" +
            "where lonbon_case.case_patient_id_card = #{idCard} \n" +
            "and lonbon_case.case_is_pigeonhole = \"是\"")
    Case selectIsPigeonholeCaseByIdCard(String idCard);


    /**
     * 根据身份证和病例ID查询病例 已归档
     * @param idCard 身份证
     * @return 病例集合
     */
    @Select("SELECT case_id,case_patient_name,case_sex,case_access_time,\n" +
            "case_birthdate,case_age,case_phone_number,case_address,\n" +
            "case_attack_date,user_id,case_admission_count,case_morbidity,\n" +
            "case_initial_diagnose,doctor_id,case_competent_physician,\n" +
            "case_final_diagnose,case_discharge_date,prescription_id,\n" +
            "case_discharge_condition,case_comment,case_is_pigeonhole,\n" +
            "case_final_update_date,case_patient_id_card from lonbon_case \n" +
            "where lonbon_case.case_patient_id_card = #{idCard} \n" +
            "and lonbon_case.case_is_pigeonhole = \"是\"")
    List<Case> selectIsPigeonholeCaseListByIdCard(String idCard);

    /**
     * 根据身份证和病例ID查询病例 已归档
     * @param idCard 身份证
     * @return 病例集合
     */
    @Select("SELECT case_id,case_patient_name,case_sex,case_access_time,\n" +
            "case_birthdate,case_age,case_phone_number,case_address,\n" +
            "case_attack_date,user_id,case_admission_count,case_morbidity,\n" +
            "case_initial_diagnose,doctor_id,case_competent_physician,\n" +
            "case_final_diagnose,case_discharge_date,prescription_id,\n" +
            "case_discharge_condition,case_comment,case_is_pigeonhole,\n" +
            "case_final_update_date,case_patient_id_card from lonbon_case \n" +
            "where lonbon_case.case_patient_id_card = #{idCard} and lonbon_case.case_id = #{caseID}\n" +
            "and lonbon_case.case_is_pigeonhole = \"是\"")
    List<Case> selectIsPigeonholeCaseListByIdCardAndCaseID(@Param("idCard") String idCard, @Param("caseID") String caseID);


    /**
     * 根据身份证查询病例 未归档
     * @param idCard 身份证
     * @return 病例
     */
    @Select("SELECT case_id,case_patient_name,case_sex,case_access_time,\n" +
            "case_birthdate,case_age,case_phone_number,case_address,\n" +
            "case_attack_date,user_id,case_admission_count,case_morbidity,\n" +
            "case_initial_diagnose,doctor_id,case_competent_physician,\n" +
            "case_final_diagnose,case_discharge_date,prescription_id,\n" +
            "case_discharge_condition,case_comment,case_is_pigeonhole,\n" +
            "case_final_update_date,case_patient_id_card from lonbon_case \n" +
            "where lonbon_case.case_patient_id_card = #{idCard} \n" +
            "and lonbon_case.case_is_pigeonhole = \"否\"")
    Case selectNotPigeonholeCaseByIdCard(String idCard);


}
